package tr.com.aliok.html5.component;

import java.awt.Color;
import java.io.IOException;
import java.util.Map;

import javax.faces.FacesException;
import javax.faces.FactoryFinder;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContextFactory;
import javax.faces.context.ResponseStream;
import javax.faces.context.ResponseWriter;
import javax.faces.lifecycle.Lifecycle;
import javax.faces.lifecycle.LifecycleFactory;
import javax.faces.render.Renderer;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;

/**
 *
 * @JSFRenderer
 *   renderKitId = "HTML_BASIC"
 *   family = "tr.com.aliok.html5.Test"
 *   type = "tr.com.aliok.html5.Test"
 * @since 0.0.1
 * @author Ali Ok
 *
 */
public class TestRenderer extends Renderer
{

    public void encodeBegin(FacesContext context, UIComponent component)
            throws IOException
    {
        TestComponent testComponent = (TestComponent) component;

        generateTestTag(context, testComponent);
    }

    public void encodeEnd(FacesContext context, UIComponent component)
            throws IOException
    {
        super.encodeEnd(context, component);
    }

    private void generateTestTag(FacesContext context, TestComponent component)
            throws IOException
    {

        ResponseWriter writer = context.getResponseWriter();
        String abc = component.getAbc();
        String def = component.getDef();

        writer.startElement(HTML.INPUT_ELEM, component);

        writer.writeAttribute(HTML.TYPE_ATTR, abc, null);

        writer.writeAttribute(HTML.VALUE_ATTR, def, null);

        writer.endElement(HTML.INPUT_ELEM);
    }
}
